﻿using UnityEngine;

namespace HKTools
{
    /// <summary>
    /// 摄像机多目标切换管理工具，BirdViewTarget 控制脚本
    /// </summary>
    public class HK_BirdViewTarget : HK_BaseTarget
    {
        public Vector3 TargetPos
        {
            get { return transform.position + transform.up * distance; }
        }

        public Vector3 TargetDir
        {
            get { return transform.position - TargetPos; }
        }

        [Header("正交尺寸："), Range(10, 50)]
        public float OrthographicSize = 20;

        [Header("默认距离（Green）：")]
        public float distance = 30;

        [Header("Area宽度：")]
        public float areaWidth = 20;

        [Header("Area长度：")]
        public float areaLength = 10;

        public override void Awake()
        {
            base.Awake();
            TargetKind = HK_TargetKind.BirdViewTarget;
        }

        // 绿色为默认目标位置，红色为最远位置，蓝色为最近位置
        void OnDrawGizmosSelected()
        {
            var radius = 1f;

            Gizmos.color = Color.green;
            Gizmos.DrawRay(transform.position, transform.up * distance);
            Gizmos.DrawSphere(transform.position + transform.up * distance, radius);

            Gizmos.DrawWireCube(transform.position + transform.up * distance, new Vector3(areaWidth, 2, areaLength));

            Gizmos.color = Color.blue;
            Gizmos.DrawRay(transform.position, transform.forward * distance / 3);
            Gizmos.DrawCube(transform.position + transform.forward * distance / 3, Vector3.one * radius / 2);
        }
    }
}